﻿<?php
	class MY_Model extends CI_Model {
		
		public function __construct(){
			parent::__construct();
		}
		
		public function testing($table,$arr){
			if ($this->db->table_exists($table)){
				$fields = $this->db->list_fields($table);
				foreach($arr as $k => $v){
					$params = array();
					//  /^([^\s]++)\s/
					preg_match_all('/(\S+)\s/',$k,$re);
					//判断键名
					if(!in_array($k,$fields)) return info(401,'参数错误',$k.'参数错误');
					if($v && is_array($v)) return info(401,'参数必须为一维数组','');
					if($v) $params[$k] = $v;
				}
				return info(200,'验证通过',$params);
			}else return info(400,'未查询到数据表','');
		}
		
		public function del(){
			
		}
		
		public function add(){
			
		}

		public function equal_select($table,$arr){
			$params = $this->testing($table,$arr);
			return $params;
			if($params->code != 200) return $params->msg;
			else{
				$this->db->select('*');
				$this->db->from($table);
				foreach($params->data as $k => $v)
					$this->db->where($k,$v);
				$query = $this ->db->get('');
				return $query->result();
			}
		}
		
		public function update(){
			
		}
	}